RandomLinearlySeparable <- function(a, b, c, n1, n2) {
  number1 = 0
  number2 = 0
  size = 0
  l = list(1:(n1+n2)*0)
  
  while (number1 != n1 || number2 != n2) {
    point = c(runif(1, 0, 1), runif(1, 0, 1))
    cond = a * point[1] + b * point[2] + c
    if (cond >= 0 && number1 < n1) {
      number1 = number1 + 1
      size = size + 1
      l[[size]] = c(point, 1)
      next
    }
    if (cond < 0 && number2 < n2) {
      number2 = number2 + 1
      size = size + 1
      l[[size]] = c(point, -1)
      next
    }
  }
  write(unlist(l), "train1.txt", ncolumn=3)
}
RandomLinearlySeparable(1, 1, -1, 100, 100)
 
